<template>
    <div>
        <myheader/>
        <table>
            <tr>
                <td>名字</td>
                <td>图片</td>
                <td>删除</td>
            </tr>
            <tr v-for="i in filelist">
                <td>{{i.name}}</td>
                <td><van-image
                      
                        width="10rem"
                        height="10rem"
                        :src="i.url"
                      /></td>
                <td><van-button @click="del(i.name)">删除</van-button></td>
            </tr>

        </table>
    </div>
</template>

<script>
import myheader from '@/components/myheader'
    export default {
        data(){
            return{
                filelist:[],
                userid:localStorage.getItem('userid')
            }
        },
        methods:{
            getFilelist(){
                this.$axios.get('users/getFiles?userid='+this.userid).then(res=>{
                    this.filelist =  res.data.list
                })
            },
            del(name){
                this.$axios.delete('users/getFiles?userid='+this.userid+'&filename='+name).then(res=>{
                    this.getFilelist()
                })
            }
        },
        mounted(){
            this.getFilelist()
        },
        components:{
            'myheader':myheader
        }
    }
</script>

<style scoped>

</style>